<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
$params =& Com_Letterman::getParams();
$ajax = $params->get('use_ajax', 0);


$css =<<<EOH
dl#system-message, dl#system-message dt, dl#system-message dd {
	margin:0;
	padding:0;
}

dl#system-message ul {
	font-weight:bold;
	min-height:30px;
	list-style: none;
	padding:5px 5px 5px 50px;
}
.progressbar_wrapper div{font:16px sans-serif;}
#wrapper{display:none;}
EOH;

$doc =& JFactory::getDocument();
$doc->addStyleDeclaration($css);



$onsubmit = '';

if($ajax){
	JHTML::script('progressbar.js', 'administrator/components/com_letterman/medias/', true);
	JHTML::script('send.js', 'administrator/components/com_letterman/medias/', false);
	$onsubmit = 'onsubmit="return sendNewsletters(this)"' ;
}
?>



<form action="<?php echo $this->getViewUrl( 'task=send&id='. $this->id .'&tmpl=component', true ) ?>" 
      method="post" <?php echo $onsubmit ?> >
	
	<fieldset><legend><?php echo JText::_('Send newsletter') ?></legend>

<?php if ($this->state < 1) : ?>
	<p>
		<label><?php echo JText::_('Mail from') ?> :<br />
		<input type="text" name="mailfrom" value="<?php echo $this->mailfrom ?>" size="30" /></label>
	</p>
	
	<p>
		<label><?php echo JText::_('Reply to') ?> :<br />
		<input type="text" name="replyto" value="<?php echo $this->replyto ?>" size="30" /></label>
	</p>
	
	<p>
		<label>
		<input type="checkbox" name="only_confirmed" value="1" <?php if( $this->only_confirmed ) echo 'checked="checked"' ?> > <?php echo JText::_('Only confirmed Accounts') ?>
		</label>
	</p>
	<p>
		<label>
		<input type="checkbox" name="textformat" value="1" > <?php echo JText::_('Text format') ?>
		</label>
	</p>
	
	<p><input type="submit" value="<?php echo JText::_('Send Now') ?>" /></p>
	<div id="wrapper">Avancement :<br /></div>
	 
<?php else : ?>
	<input type="hidden" name="mailfrom" value="<?php echo $this->mailfrom ?>" />
	<input type="hidden" name="replyto" value="<?php echo $this->replyto ?>" />
	<input type="hidden" name="only_confirmed" value="<?php echo $this->only_confirmed ? '1':'0' ?>" />
	<input type="hidden" name="limitstart" value="<?php echo $this->response->nextlimitstart ?>" />
	<div>Avancement : <strong> <?php echo $this->response->percent ?> %</strong></div>
	
	<?php if ($this->response->nextlimitstart < $this->response->total ) :?>
		<p><input type="submit" value="<?php echo JText::_('Next') ?> &gt;&gt;" /></p>
	<?php endif ?>
	
<?php endif ?>
	
	</fieldset>
</form>

